var t = getApp();

Page({
    data: {
        condition: !0,
        urlid: "",
        key: "",
        Back: "",
        pretext: "",
        itemList: [],
        htitemName: "",
        netbol: !0,
        hintbol: !0
    },
    loadData: function(a) {
        var e = this, i = a + "_reflist", n = a + "_Name", o = "def_" + a, d = "hint_" + a;
        wx.showToast({
            title: "数据加载中",
            icon: "loading",
            duration: 2e4
        }), wx.request({
            url: t.url + "addon/Defdetail/Defdetail/" + t.globalData.ItemrefUrl,
            data: {
                keyname: a
            },
            method: "GET",
            header: {
                "content-type": "application/json",
                Cookie: "PHPSESSID=" + wx.getStorageSync("PHPSESSID")
            },
            success: function(a) {
                wx.hideToast();
                var s = a.data, l = [ s.text1, s.text2, s.text3, s.text4, s.text5, s.text6, s.text7, s.text8, s.text9, s.text10, s.text11, s.text12 ].filter(function(t) {
                    return void 0 !== t && null !== t && t.length > 0;
                });
                e.setData({
                    itemList: l,
                    deftext: a.data.deftext,
                    htitemName: a.data.htitemName,
                    hintext: a.data.hintext
                }), a.data.hintext || e.setData({
                    hintbol: !1
                }), t.globalData[i] = l, wx.setStorageSync(i, l), t.globalData[n] = a.data.htitemName, 
                wx.setStorageSync(n, a.data.htitemName), t.globalData[d] = a.data.hintext, wx.setStorageSync(d, a.data.hintext), 
                wx.setStorageSync(o, a.data.deftext);
            },
            fail: function(t) {
                wx.hideToast();
                var a = wx.getStorageSync(i), o = wx.getStorageSync(n), s = wx.getStorageSync(d);
                s || e.setData({
                    hintbol: !1
                }), e.setData({
                    itemList: a,
                    htitemName: o,
                    hintext: s
                }), a || (e.setData({
                    netbol: !1
                }), wx.showToast({
                    title: "无法连接网络",
                    icon: "loading",
                    duration: 2500
                }));
            }
        });
    },
    onLoad: function(a) {
        this.setData({
            urlid: a.urlid,
            key: a.key,
            Back: a.Back,
            url: a.url,
            id: a.id,
            sessin: a.sessin,
            word: a.word
        });
        var e = a.key + "_reflist", i = a.key + "_Name", n = "hint_" + a.key, o = t.globalData[e], d = t.globalData[i], s = t.globalData[n];
        o ? (this.setData({
            itemList: o,
            htitemName: d,
            hintext: s
        }), s || this.setData({
            hintbol: !1
        })) : this.loadData(a.key);
    },
    onReady: function() {
        2 == this.data.Back && this.setData({
            condition: !1
        });
    },
    SelectText: function(a) {
        var e = this.data.itemList[a.target.dataset.id];
        t.globalData.tempDetail;
        t.globalData.tempDetail = e;
    },
    AddText: function(a) {
        var e = this.data.itemList[a.target.dataset.id], i = t.globalData.tempDetail;
        t.globalData.tempDetail = i + "\n" + e;
    },
    bindreturn: function() {
        var t = this.data.key, a = this.data.Back;
        wx.redirectTo({
            url: "../SdraftDetail/SdraftDetail?key=" + t + "&Back=" + a + "&From=0&url=" + this.data.url + "&id=" + this.data.id + "&sessin=" + this.data.sessin + "&word=" + this.data.word
        });
    }
});